package com.yigo.cuc.gateway.controller;

import com.yigo.cuc.api.customer.CustomerFeign;
import com.yigo.cuc.api.customer.command.CustomerRegisterCmd;
import com.yigo.cuc.api.customer.command.UpdateNickNameCmd;
import com.yigo.cuc.api.customer.resp.CustomerRegisterResp;
import com.yigo.cuc.app.service.CustomerAppService;
import com.yigo.framework.http.Q;
import com.yigo.framework.http.R;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author chenzl
 */
@RestController
public class CustomerController implements CustomerFeign {
    @Resource
    private CustomerAppService customerAppService;

    @Override
    public R<CustomerRegisterResp> register(Q<CustomerRegisterCmd> q) {
        return R.ok(customerAppService.register(q.getNonNullParams()));
    }

    @Override
    public R<String> updateNickName(Q<UpdateNickNameCmd> q) {
        Long id = customerAppService.updateNickName(q.getNonNullParams());
        return R.ok(String.valueOf(id));
    }
}
